﻿using IdentityServer4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyIdentityServer
{
    // 身份服务配置类
    public class Config
    {
        /// <summary>
        /// 获取API资源集
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<ApiResource> GetApiResources()
        {
            return new List<ApiResource>
            {
                new ApiResource("api1", "api1 显示的名称")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = "clientId", //客户度编号
                    AllowedGrantTypes = GrantTypes.ClientCredentials, //授权类型
                    ClientSecrets = { new Secret("secret".Sha256()) }, //客户端隐私
                    AllowedScopes = { "api1" } //允许的作用域,也就是可以访问哪些APIs
                }
            };
        }

        //...
    }
}
